﻿Imports System.Drawing
Imports AdvanceWars.Data

Public Class Unit
    'Inherits AStarNode

#Region "data"

    Public Id As Integer
    Public Type As UnitType
    Public HP As PairValue
    Public Owner As Player
    Public State As UnitState

    ''' <summary>
    ''' 日常?
    ''' </summary>
    Public Base As UnitAbility
    Public Power As UnitAbility
    Public SPower As UnitAbility

    Public Location As Point
    Public ReadOnly Oil As PairValue
    Public ReadOnly Color As Byte
    Public Vision As Integer

#End Region

    Sub New(ByVal Owner As Player, ByVal UnitTypeId As Integer)
        Me.New(Owner, UnitTypeId, 10)
    End Sub

    Sub New(ByVal Owner As Player, ByVal UnitTypeId As Integer, ByVal Hp As Integer)
        Me.Owner = Owner
        Me.Type = DataService.UnitFactory(UnitTypeId)
        Me.Oil = New PairValue(Type.MaxOil)
        Base = New UnitAbility
        Base.PrimaryWeapon = New Weapon(Type.PrimaryWeaponId)
        Base.SecondaryWeapon = New Weapon(Type.SecondaryWeaponId)

        Me.HP = New PairValue(10, Hp)
    End Sub

    ''' <summary>
    ''' 修复
    ''' </summary>
    Sub Repair(ByVal repairHp As Integer)
        HP.Value += repairHp
    End Sub

    ''' <summary>
    ''' 补给
    ''' </summary>
    Sub Supply()
        Oil.Value = Oil.Origin
        Dim ammo As PairValue = Me.Base.PrimaryWeapon.Ammo
        ammo.Value = ammo.Origin
    End Sub

    Private Function GetFireRangeUnit(ByVal Point As Point, ByVal Range As Range) As List(Of Unit)
        Return Nothing
    End Function

    Public Event Fire(ByVal sender As Object)

    Public Event Dead(ByVal sender As Object)

End Class
